window.onload=function (){
    findByItem(1);
}

/**
 * 动态条件分页查询
 * @param pageNO 页码
 */
function findByItem(pageNO){
    axios.get("/product/findByItem",{
        params: {
            pageNO,
            name:$("nameTxt").value,
            startDate:$("startTxt").value,
            endDate:$("endTxt").value
        }
    }).then(resp =>{
        let info =resp.data;
        let str ="";
        info.list.forEach(n =>{
            str += `<tr><td>${n.name}</td><td>${n.createDate}</td><td>${n.price}</td><td><a href="/product/update.html?id=${n.id}">修改</a></td></tr>`
        })
        $("data").innerHTML=str;
        //页码
        let pageStr ="";
        for (let i = 1; i < info.totalPage; i++) {
            pageStr +=`<a href="javascript:findByItem(${i})" style="margin-left: 10px">${i}</a>`
        }
        $("cutDiv").innerHTML=pageStr;
    });
}